package com.woniu.microchargeserver.chargemag.service.impl;

import com.woniu.microchargeserver.chargemag.service.IRoomAdvanceDepositService;
import com.woniu.microchargeserver.common.mapper.RoomAdvanceDepositMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**抵押金、房间的中间表 业务接口
 * @author: hejie
 * @date: 2021/2/3 18:00
 * @description:
 */
@Service
@Transactional(readOnly = true)
public class RoomAdvanceDepositServiceImpl implements IRoomAdvanceDepositService {

    @Resource
    private RoomAdvanceDepositMapper roomAdvanceDepositMapper;

    /**
     * 根据 房间id，修改该房间对应的 预收金表记录
     * charge_type  :'收费类型。1-押金，2-预收金';本方法只修改“预收金”
     * @param rid 房间id （一个房间只维护一个 预收金记录：加加减减）
     * @param remainMoneyIncrement 预收金的增量
     * @param rid
     * @return
     */
    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public int updateAdvanceDepositByRid(Long rid, Double remainMoneyIncrement){
        return roomAdvanceDepositMapper.updateAdvanceDepositByRid(rid, remainMoneyIncrement);
   }

}
